function $(id){return document.getElementById(id);}
var Search = {
	orig : '输入企业名称或地址',
	init : function(){
		$('search_name').onfocus = function(){
			if(this.value == Search.orig){
				this.value = '';
			}
		}
		$('search_name').onblur = function(){
			if(this.value == ''){
				this.value = Search.orig;
			}
		}
	}
}
function isLogin()
{
	user_id = getCookie('id','1');
	if(user_id != ""){return true;}else{return false;}
}
function checkLogin()
{
	if(isLogin()){
		var user_name = getCookie('unicodeUsername');
		var login_str = '<div class="right"><a href="/mypage.php"><img src="/images/header_mypage_off.gif" title="我的主页" alt="我的主页" /></a><a href="/logout.php"><img src="/images/header_logout_off.gif" title="退出"  alt="退出"/></a><a href=javascript:AddFavorite("http://www.87dianping.com","百企点评");><img src="/images/header_col_off.gif" title="收藏本站" /></a></div><div class="login"><span>'+user_name+',欢迎您！</span></div>';
		$('check_login').innerHTML(login_str);
	}
}
//flag 1 不需要解码
function getCookie(sName,flag)
{
	sName = "d_"+sName;
	var aCookie = document.cookie.split("; ");
	var v_name = "";
	for(var i=0;i<aCookie.length;i++)
	{
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0])
		{		
			if(flag==undefined){
				v_name = "";
				var v= unescape(aCrumb[1]).split('%');
				if(v.length>1){
					for(i=0;i<v.length;i++){
						if(v[i]>0) v_name +=String.fromCharCode(v[i]);
					}
				}
				return v_name;
			}
			return aCrumb[1];
		}
	}
	return "";
}
function smartRollover() {   
    if(document.getElementsByTagName) {   
        var images = document.getElementsByTagName("img");   
        for(var i=0; i < images.length; i++) {   
            if(images[i].getAttribute("src").match("_off."))   
            {   
                images[i].onmouseover = function() {   
                    this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));   
                }   
                images[i].onmouseout = function() {   
                    this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));   
                }   
            }   
        }   
    }   
}   
if(window.addEventListener) {   
    window.addEventListener("load", smartRollover, false);   
}   
else if(window.attachEvent) {   
    window.attachEvent("onload", smartRollover);   
} 